#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#define FILENAME "txt.txt"
int main()
{
    int ret = open(FILENAME,O_WRONLY|O_CREAT|O_APPEND,0666);
    printf("ret:%d\n",ret);
    if(ret == -1)
    {
        perror("open file fail!");
        return 1;
    }
    const char* str = "hello world";
    write(ret,str,strlen(str));

    printf("%d\n",stdin->_fileno);
    printf("%d\n",stdout->_fileno);
    printf("%d\n",stderr->_fileno);
    close(ret); // 添加这一行，确保文件正确关闭
    return 0;
}
